<template>
  <div class="container">
     <div class="corde" v-if="list.status == 1">
         <x-dialog :show.sync="show2" class="dialog-demo">
            <div class="img-box">
              <p class="btn">优惠码:{{list.code}}</p>
              <p class="btn">专属推广二维码 </p> 
              <qrcode :value="codeCom"  :size="500"  type="img"></qrcode>
            </div>
            <div @click="show2=false">
              <span class="vux-close"></span>
            </div>
          </x-dialog>
    </div>
    <div class="form" v-else>
       <div class="form-box">
          <x-input title="手机号" label-width="170px" name="mobile" v-model="phone" placeholder="请输入手机号码" keyboard="number" is-type="china-mobile"></x-input>
       </div>
       <div class="address-bom flex" @click="submit">
            提交
        </div>
    </div>
   
  </div>
</template>
<script>
import { XInput,XDialog,Qrcode,Toast} from 'vux'

export default {
  components:{
     XInput,XDialog,Qrcode
   },
  data () {
      return {
        phone: "",
        show2:true,
        list:[],
        codeCom:''
      }
    },
    mounted(){
       this.gethstatus()
    },
    methods:{
      submit(){
          let data={
            userId:this.$route.query.userId,
            phone:this.phone
          }
          let self=this
            this.$axios.post('/device/broker/add',data).then(res=>{
              if(res.data.code==1000){
               self.$vux.alert.show({
                    title: '已提交',
                    content: "您的申请已提交，请等待平台审核",
                    onShow () {
                       self.$router.push({ path: '/Personal', query: { userId: self.$route.query.userId }})
                    },
                    onHide () {
                    }
                })
                 
             }
           })
      },
      gethstatus(){
        let data={
          pageNumber:1, 
          pageSize:10,
          param: {userId:this.$route.query.userId}
        }
        let self=this
        console.log(data)
        this.$axios.post('/device/broker/lists',data).then(res=>{
            if(res.data.code==1000){
              console.log(res)
               self.list=res.data.data.list[0]
              //  http://www.chenyekeji.com/cy_market/device/pay/redirect?url=index
               self.codeCom="http://www.chenyekeji.com/cy_market/device/pay/redirect?url=index&parentId="+self.$route.query.userId
               if(self.list==0){
                 self.$vux.alert.show({
                    title: '请稍候',
                    content: "您的申请已提交，请等待平台审核",
                    onShow () {
                       self.$router.push({ path: '/Personal', query: { userId: self.$route.query.userId }})
                    },
                    onHide () {
                    }
                })
               }
            }
           })
      }
    }
}
</script>

 <style lang="less" scoped>
@import '~vux/src/styles/close';

.dialog-demo {
  .btn{
    padding:6px 46px;
    text-align: left;
  }
  .img-box{
    height:600px;
    
    padding-top: 40px;
    overflow: hidden;
    font-size: 30px;
  }
  .dialog-title {
    line-height: 30px;
    color: #666;
  }
  .vux-close {
    margin-top: 8px;
    margin-bottom: 8px;
  }
}
  .form-box{
    background: #fff;
  }
 .container{
      height: 100%;
      width:100%;
      background: #f6f6f6;
  }
  .address-bom{
    width:80%;
    margin: 100px auto;
    border-radius: 100px;
    height:78px;
    align-items:center;
    background: #eb494a;
    line-height: 78px;
    font-size: 36px;
    color: #fff;
    justify-content: center;
    display: flex;
    z-index: 999;
  }
</style>
